<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>日志展示</title>
    <link rel="stylesheet" href="css/list.css">
    <link rel="stylesheet" href="css/blog_log.css">
    <style>
        .nav{
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            height: 50px;
        }
        .container{
            padding-top: 80px;
            height: auto;
        }
        .container-right{
            width: auto;
        }
        .blog-pagnation-wrapper{
            height: 40px;
            margin: 16px 0;
            text-align: center;
        }
        .blog-pagnation-item{
            display: inline-block;
            padding: 8px;
            border: 1px solid #d0d0d5;
            color: #333;
        }
        .blog-pagnation-item:hover{
            background: #4e4eeb;
            color: #fff;
        }
        .blog-pagnation-item.actvie{
            background: #4e4eeb;
            color: #fff;
        }

    </style>
    <script src="js/jquery.min.js"></script>
    <script src="js/common.js"></script>

    <!-- 引入Bootstrap样式库 -->
    <link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.0.2/css/bootstrap.min.css">
</head>
<body>
    <!-- 导航栏 -->
    <div class="nav">
        <img src="img/Rain.jpg" alt="">
        <span class="title">我的博客系统</span>
        <!-- 用来占据中间位置 -->
        <span class="spacer"></span>
        <a href="blog_list.html">主页</a>
        <a href="blog_add.html">写博客</a>
        <a href="blog_log.html">日志</a>
        <a href="blog_recycle.html">回收站</a>
        <a href="javascript:logout()">注销</a>
        <!-- <a href="#">注销</a> -->
    </div>

    <div class="container">
        <h1 class="text-center my-5">日志信息</h1>
        <table class="table table-striped">
            <thead>
                <tr>
                    <th>时间</th>
                    <th>级别</th>
                    <th>内容</th>
                </tr>
            </thead>
            <tbody id="log-table-body">
            </tbody>
        </table>
    </div>
    <!-- 引入jQuery库 -->
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
    <script>
        $(function() {
            // 向后端发送请求，获取日志信息
            $.ajax({
                url: '/log/getLog',
                type: 'GET',
                dataType: 'json',
                success: function(result) {
                    // 遍历日志信息，将每行日志添加到表格中

                    for(var i =0; i < result.data.length; i++) {
                        var log = result.data[i];
                        var tr = $('<tr>');
                        tr.append($('<td>').text(log.log_Create));
                        tr.append($('<td>').text(log.log_Level));
                        tr.append($('<td>').text(log.log_Method));
                        $('#log-table-body').append(tr);
                    }
                   
                },
                error: function() {
                    alert('获取日志信息失败！');
                }
            });
        });
    </script>
</body>
</html>